<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:h="jakarta.faces.html" xmlns:f="jakarta.faces.core" xmlns:ui="jakarta.faces.facelets"
    xmlns:p="http://primefaces.org/ui" xmlns:pe="http://primefaces.org/ui/extensions" xmlns:o="http://omnifaces.org/ui"
    xmlns:sec="https://joinfaces.org/security"
          template="/WEB-INF/template.xhtml">
    <!--template="/template.xhtml">-->
    <ui:define name="implementation">


        <p:dataTable id="sysParams" widgetVar="sysParamTable" var="c" value="#{sysParamMB.lazyModel}" rows="10"
                     rowKey="#{c.id}" lazy="true" paginator="true" paginatorPosition="bottom"
                     paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown} {JumpToPageDropdown}"
                     currentPageReportTemplate="[ {startRecord} to {endRecord} of {totalRecords} ]"
                     rowsPerPageTemplate="5,10,20,30,50,100,200,300,500,1000" draggableColumns="true"
                     resizableColumns="true"
                     liveResize="true" showGridlines="true" scrollable="true" scrollHeight="660" multiViewState="false"
                     selectionMode="multiple" selection="#{sysParamMB.multipleSelected}"
                     globalFilterOnly="#{sysParamMB.globalFilterOnly}"
        >
            <f:facet name="header">
                <p:toolbar>
                    <p:toolbarGroup align="left" class="grid">
                        <p:commandButton id="delete-multiple-button" value="#{sms['button.delMultiple']}"
                                         icon="pi pi-trash" actionListener="#{sysParamMB.delMultiple}"
                                         styleClass="ui-button-danger ml-2 col" update="sysParams">
                            <p:confirm header="#{sms['confirm.title']}" message="#{sms['confirm.message']}"
                                       icon="pi pi-exclamation-triangle"/>
                        </p:commandButton>
                        <p:tooltip for="delete-multiple-button" value="#{sms['button.delete.tip']}" showEffect="clip"
                                   hideEffect="fold"/>
                        <p:commandButton id="newObj" value="#{sms['button.new']}" icon="pi pi-plus"
                                         styleClass="ml-2 col" action="#{sysParamMB.newOpt('sysParamForm')}">
                            <p:ajax event="dialogReturn"   oncomplete="PF('sysParamTable').filter()"  update="@form"/>
                        </p:commandButton>
                        <p:tooltip for="newObj" value="#{sms['button.new.tip']}" showEffect="clip" hideEffect="fold"/>

                        <p:commandButton id="editObj" value="#{sms['button.edit']}" icon="pi pi-file-edit"
                                         styleClass="ml-2 col" action="#{sysParamMB.editOpt('sysParamForm')}">
                            <p:ajax event="dialogReturn"   oncomplete="PF('sysParamTable').filter()"  update="@form"/>
                        </p:commandButton>
                        <p:tooltip for="editObj" value="#{sms['button.edit.tip']}" showEffect="clip"
                                   hideEffect="fold"/>
                    </p:toolbarGroup>
                    <p:toolbarGroup align="center" class="grid">
                        <p:commandButton value="xls" icon="pi pi-upload" styleClass="ml-2 col" ajax="false">
                            <p:dataExporter type="xls" target="sysParams" fileName="cars"/>
                        </p:commandButton>
                        <p:commandButton value="xlsx" icon="pi pi-upload" styleClass="ml-2 col" ajax="false">
                            <p:dataExporter type="xlsx" target="sysParams" fileName="cars"/>
                        </p:commandButton>
                        <p:commandButton value="csv" icon="pi pi-upload" styleClass="ml-2 col" ajax="false">
                            <p:dataExporter type="csv" target="sysParams" fileName="cars"/>
                        </p:commandButton>
                        <p:commandButton value="xml" icon="pi pi-upload" styleClass="ml-2 col" ajax="false">
                            <p:dataExporter type="xml" target="sysParams" fileName="cars" pageOnly="true"/>
                        </p:commandButton>
                    </p:toolbarGroup>

                    <p:toolbarGroup align="right" class="grid">
                        <p:commandButton id="refresh" icon="pi pi-refresh" update="@form" styleClass="ml-2 col"
                                         onclick="PF('sysParamTable').filter()"/>
                        <p:tooltip for="refresh" value="#{sms['button.refresh.tip']}" showEffect="clip"
                                   hideEffect="fold"/>
                        <p:commandButton id="filterSwitch"
                                         icon="#{c.globalFilterOnly== true? 'pi pi-search-minus': 'pi pi-search-plus'}"
                                         update="@form" styleClass="ml-2 col"
                                         action="#{sysParamMB.toggleGlobalFilter()}"/>
                        <p:tooltip for="filterSwitch" value="#{sms['button.filter.toggle.tip']}" showEffect="clip"
                                   hideEffect="fold"/>
                        <p:commandButton id="toggler" type="button" icon="pi pi-objects-column" styleClass="ml-2 col"/>
                        <p:tooltip for="toggler" value="#{sms['button.column.toggle.tip']}" showEffect="clip"
                                   hideEffect="fold"/>
                        <p:columnToggler datasource="sysParams" trigger="toggler">
                            <p:ajax event="toggle" listener="#{sysParamMB.onToggle}"/>
                        </p:columnToggler>
                    </p:toolbarGroup>
                </p:toolbar>
            </f:facet>

            <p:column selectionBox="true" style="width:16px;text-align:center" exportable="false"/>

            <p:column headerText="ID" sortBy="#{c.id}" filterBy="#{c.id}" visible="true" filterMatchMode="exact">

                <h:outputText value=" #{c.id}"/>
            </p:column>
            <p:column headerText="#{sms['sys.parameter.name']}" sortBy="#{c.name}" filterBy="#{c.name}" visible="true">
                <h:outputText value=" #{c.name}"/>
            </p:column>


            <p:column headerText="#{sms['sys.parameter.value']}" sortBy="#{c.value}" filterBy="#{c.value}"
                      visible="true">
                <h:outputText value=" #{c.value}"/>
            </p:column>
            <p:column headerText="#{sms['sys.parameter.key']}" sortBy="#{c.key}" filterBy="#{c.key}" visible="true">
                <h:outputText value=" #{c.key}"/>
            </p:column>


            <p:column headerText="#{sms['sys.parameter.state']}" width="100" sortBy="#{c.state}" filterBy="#{c.state}"
                      visible="true" filterMatchMode="equals" exportable="false">

                <f:facet name="filter">
                    <p:selectOneMenu onchange="PF('sysParamTable').filter()" styleClass="ui-custom-filter"
                                     converter="jakarta.faces.Boolean">
                        <f:selectItem itemLabel="All" itemValue="#{null}"/>
                        <f:selectItem itemLabel="#{sms['common.yes']}" itemValue="true"/>
                        <f:selectItem itemLabel="#{sms['common.no']}" itemValue="false"/>
                    </p:selectOneMenu>
                </f:facet>
                <h:outputText value="#{c.state== true ? sms['common.yes'] : sms['common.no']}"/>
            </p:column>
            <p:column headerText="#{sms['sys.parameter.remark']}" sortBy="#{c.remark}" filterBy="#{c.remark}"
                      visible="true">
                <h:outputText value=" #{c.remark}"/>
            </p:column>
            <p:column headerText="#{sms['common.audit.createtime']}"
                      sortBy="#{c.createTime}" filterBy="#{c.createTime}"
                      visible="false">
                <h:outputText value=" #{c.createTime}">
                    <f:convertDateTime pattern="yyyy-MM-dd"/>
                </h:outputText>
            </p:column>
            <p:column headerText="#{sms['common.audit.createuser']}" sortBy="#{c.createUser}" filterBy="#{c.createUser}"
                      visible="false">
                <h:outputText value=" #{c.createUser}"/>
            </p:column>
            <p:column headerText="#{sms['common.audit.updatetime']}" sortBy="#{c.updateTime}" filterBy="#{c.updateTime}"
                      visible="true">
                <h:outputText value=" #{c.updateTime}">
                    <f:convertDateTime  pattern="yyyy-MM-dd"/>
                </h:outputText>
            </p:column>
            <p:column headerText="#{sms['common.audit.updateuser']}" sortBy="#{c.updateUser}" filterBy="#{c.updateUser}"
                      visible="false">
                <h:outputText value=" #{c.updateUser}"/>
            </p:column>
        </p:dataTable>
    </ui:define>
</ui:composition>